package org.chw.handler;

import com.netflix.appinfo.HealthCheckHandler;
import com.netflix.appinfo.InstanceInfo.InstanceStatus;
import org.chw.indicator.AppIndicator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.health.Status;
import org.springframework.stereotype.Component;


/* *
  *@ClassName AppHandler
  *@Author chen
  *@Description TODO
  *@Date 2018/5/25 19:18
  *@Version 1.0    
**/
@Component
public class AppHandler implements HealthCheckHandler {
    @Autowired
    private AppIndicator appIndicator;

    public InstanceStatus getStatus(InstanceStatus instanceStatus) {
        Status status = this.appIndicator.health().getStatus();
        if (status.equals(Status.UP)) {
            return InstanceStatus.UP;
        } else {
            return InstanceStatus.DOWN;
        }
    }
}